package com.zgw.his.design.editor;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wb.internal.core.xml.editor.AbstractXmlEditor;
import org.eclipse.wb.internal.core.xml.editor.XmlDesignPage;

import com.zgw.his.design.model.Template;
import com.zgw.his.design.resource.MedicalResourceManager;

@SuppressWarnings("restriction")
public class MedicalEditor extends AbstractXmlEditor {
	public static final String ID = "com.zgw.his.design.editor.MedicalEditor";
	private Template medicalTemplate;
	private MedicalResourceManager resourceManager;

	// //////////////////////////////////////////////////////////////////////////
	//
	// Pages
	//
	// //////////////////////////////////////////////////////////////////////////
	@Override
	protected XmlDesignPage createDesignPage() {
		return new MedicalDesignPage();
	}

	public void initialize(Template medicalTemplate,
			MedicalResourceManager resourceManager) {
		this.medicalTemplate = medicalTemplate;
		this.resourceManager = resourceManager;
	}

	@Override
	public void doSave(IProgressMonitor monitor) {
		super.doSave(monitor);
	}

	public Template getMedicalTemplate() {
		return medicalTemplate;
	}

	public MedicalResourceManager getResourceManager() {
		return resourceManager;
	}

	public void setMedicalTemplate(Template medicalTemplate) {
		this.medicalTemplate = medicalTemplate;
	}

	public void setResourceManager(MedicalResourceManager resourceManager) {
		this.resourceManager = resourceManager;

	}

	@Override
	protected void setPartName(String partName) {
		if (medicalTemplate != null)
			super.setPartName(medicalTemplate.getName());
		else
			super.setPartName(partName);
	}

	public void refreshUI() {
		this.setPartName(medicalTemplate.getName());
	}

}
